// src/api/index.js 保存项目所有请求方法
// 1:引入刚才创建ajax函数
import ajax from './ajax'
// 2:创建常量保存请求服务器基础路径
// const BASE_URL = "http://127.0.0.1:4000"
const BASE_URL = '/api'
// 3:创建函数 reqPwdLogin 向服务器发请求完成登录 
export const reqPwdLogin = ({name2, pwd2}) => ajax(BASE_URL + '/login_pwd', {name2, pwd2}, 'POST')
//注册
export const reqRegister = ({name1, pwd1,tel}) => ajax(BASE_URL + '/register', {name1, pwd1,tel}, 'POST')
//充值
export const reqChongZhi = ({money1,money2}) => ajax(BASE_URL + '/chongzhi', {money1,money2}, 'POST')
//结算
export const reqJieSuan = ({yu}) => ajax(BASE_URL + '/jiesuan', {yu}, 'POST')
//创建订单
export const reqCreateOrder = ({fname,fprice,fcount}) => ajax(BASE_URL + '/create_order', {fname,fprice,fcount}, 'POST')
//获取订单
export const reqGetOrders = () => ajax(BASE_URL + '/get_orders')
// 4:创建函数 reqUserInfo 向服务器发请法完成用户信息获取
export const reqUserInfo = () => ajax(BASE_URL + '/userinfo')
//创建函数reqLogout向服务器发送请求完成用户退出操作
export const reqLogout= ()=>ajax(BASE_URL+"/logout")
//获取商家列表
export const reqShops= ()=>ajax(BASE_URL+"/stores")
//获取某个商家
export const reqShop= ({sid})=>ajax(BASE_URL+"/store",{sid},'POST')
//获取某商家的商品类别信息
export const reqShopCategory= ({sid})=>ajax(BASE_URL+"/category",{sid},'POST')
//获取某商家的商品信息
export const reqShopfoods= ({sid})=>ajax(BASE_URL+"/foods",{sid},'POST')
//请求函数,请求模拟服务器
export const reqShopInfo= ()=>ajax("/info");
export const reqShopGoods= ()=>ajax("/goods");
export const reqShopRatings= ()=>ajax("/ratings");